home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #2 / Amiga Plus CD - 1999 - No. 2.iso / System-Boost / Grafik / MetaView / ARexx-Examples / Example_Export.rexx < prev    next >
OS/2 REXX Batch file  |  1998-11-08  |  2KB  |  118 lines

  1. /* Graphik Export mittels MetaView */
  2.  
  3. METAVIEW = ':Aminet/MetaView/MetaView'    /* Please complete the path */
  4.  
  5. OPTIONS RESULTS
  6. SIGNAL ON FAILURE
  7. SIGNAL ON SYNTAX
  8.  
  9. /*
  10. ** Looking for our start process
  11. */
  12.  
  13. APLPORT = ADDRESS()
  14. say APLPORT
  15. if (LEFT(APLPORT, 10) ~= "APPLICATION") then do /* not started from Application */
  16.     say "Please start me from Application!"
  17.     EXIT
  18. end
  19.  
  20. /*
  21. ** Create a new Metaview process:
  22. ** first look for the allready running processes
  23. ** then the new Port will be the next one
  24. */
  25.  
  26. do NUMBER = 0 to 20
  27.     if (SHOW(PORTS,"METAVIEW." || NUMBER) = 0) then
  28.     leave
  29. end
  30.  
  31. /*
  32. ** Searching for MetaView: 1. our path above,
  33. **    2. path in env:MetaView.path
  34. ** or 3. you must have a assign "MetaView:"
  35. */
  36.  
  37. if (EXISTS(METAVIEW)=0) then do
  38.     if OPEN("MVVAR","env:MetaView.path","Read") then do
  39.         METAVIEW = READLN("MVVAR")
  40.     end
  41.     if (EXISTS(METAVIEW)=0) then do
  42.         METAVIEW = "MetaView:MetaView"
  43.     end
  44. end
  45.  
  46. /*
  47. ** Enable warnings for WaitForPort
  48. */
  49.  
  50. OPTIONS FAILAT 5
  51. ADDRESS COMMAND
  52.     "run " || METAVIEW || " NODISPLAY"
  53.     MVPORT = "METAVIEW." || NUMBER
  54.     "WaitForPort " || MVPORT
  55.  
  56. /*
  57. ** Ignore the other errors
  58. */
  59.  
  60. OPTIONS FAILAT 21
  61.  
  62. /*
  63. **  Export the temporary file in application
  64. */
  65.  
  66. ADDRESS VALUE APLPORT
  67.     SAVE "t:test.dr2d"
  68.  
  69. /*
  70. ** Do all needed thinks with MetaView (LOAD,SAVE,QUIT...)
  71. */
  72.  
  73. ADDRESS VALUE MVPORT
  74.     LOAD "t:test.dr2d"
  75.     REQUESTCHOICE TITLE "Request" BODY """Choose the format to save""" BUTTONS "AMF|WMF|DR2D|CGM|GEM|EPS|AI|HPGL|ILBM"
  76.     CHOICE = rc
  77.     REQUESTFILE "RAM:" TITLE """Please choose filename"""
  78.     FILENAME = result
  79.     if (CHOICE = 1) then do
  80.       SAVE FILENAME AS AMF
  81.     end
  82.     if (CHOICE = 2) then do
  83.       SAVE FILENAME AS WMF
  84.     end
  85.     if (CHOICE = 3) then do
  86.       SAVE FILENAME AS DR2D
  87.     end
  88.     if (CHOICE = 4) then do
  89.       SAVE FILENAME AS CGM
  90.     end
  91.     if (CHOICE = 5) then do
  92.       SAVE FILENAME AS GEM
  93.     end
  94.     if (CHOICE = 6) then do
  95.       SAVE FILENAME AS EPS
  96.     end
  97.     if (CHOICE = 7) then do
  98.       SAVE FILENAME AS AI
  99.     end
  100.     if (CHOICE = 8) then do
  101.       SAVE FILENAME AS HPGL
  102.     end
  103.     if (CHOICE = 0) then do
  104.       SAVE FILENAME AS ILBM
  105.     end
  106.     QUIT
  107.  
  108. EXIT
  109.  
  110. FAILURE:
  111.     ADDRESS COMMAND
  112.     REQUESTCHOICE "Error" """Can't find" METAVIEW "!""" "OK"
  113.     EXIT
  114.  
  115. SYNTAX:
  116.     say "Error on line" SIGL ":" ERRORTEXT(RC) "!"
  117.     EXIT
  118.